home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / raytrace / pxm_ray / pxm_ray.txt < prev   
Text File  |  1992-12-09  |  3KB  |  82 lines

  1.  
  2.     Here is a simple ray tracing program developed here at RPI.  It
  3. incorporates shadows, reflections and refraction together with one
  4. non-directional light source.  The light source can diffuse on the surfaces
  5. and can also give specular reflections.  The illumination model used is
  6. by Phong.  The only objects supported right now are spheres, but the data
  7. structure can be easily expanded to incorporate more objects.
  8.     Here is a list of the files, and what does each file contain:
  9.  
  10. bg.c:        bgcolor()    evaluates the background color for a given ray.
  11.  
  12. initialize.c:    initialize()    does some useful setup.
  13.  
  14. intersect.c:    sphere()    Intersection routine with a sphere.
  15.         intersect()    Main intersection routine  (calls sphere() ).
  16.  
  17. main.c:        main()        Main body of the program.
  18.  
  19. readfile.c:    readfile()    Reads in the input data.
  20.  
  21. shade.c:    shadow()        Calculates the existance of a shadow ray.
  22.         reflect()    Find the reflection vector.
  23.         refract()    Find the refraction vector.
  24.         shade()        Calculate Phong's shading function.
  25.  
  26. trace.c:    trace()        Trace a single ray.
  27.         raytrace()    Ray trace the whole picture.
  28.  
  29. vector.c:    vadd()        vector addition.
  30.         vsub()        vector subtraction.
  31.         vneg()        vector negation.
  32.         svproduct()    scalar - vector product.
  33.         vdot()        dot product.
  34.         vcross()    cross product.
  35.         norm()        normalize a vector.
  36.  
  37. ray.h:        Include file for every file used in the raytracer.
  38.  
  39. vector.h:    Include file for every file using vectors.
  40.  
  41.  
  42.  
  43.     The ray tracer is written so it can be easily understood (at least
  44. that version), and it is fully commented.  Nevertheless, probably it won't
  45. be understood by a newcomer.  
  46.  
  47.     The format of the input file is as follows:
  48.  
  49. light
  50. nos
  51. x y z r [ambient] [diff] [spec] refl r g b refr r g b width index
  52.  
  53. where:
  54.  
  55. light        x y z components of the light source.
  56. nos        num,ber of spheres
  57. [ambient]    r g b components of ambient
  58. [diff]        r g b components of diffuse
  59. [spec]        r g b components of specular
  60. refl r g b    reflection ratio and color of the reflection
  61. refr r g b    refraction ratio and color of the refraction
  62. width        specular width exponent
  63. index        index of refraction
  64.  
  65.     The format of the output file is simple.  In the beginning there are
  66. 2 integers (that can be read with fread() on a SUN) showing xsize and ysize
  67. of the picture.  After that follow the pixels in scan-line order.  Each pixel
  68. uses 3 bytes (one for red, green and blue), totalling 16777216 colors.  You
  69. can change the format of that file to tailor your needs.  It can be done
  70. easily by changing the funcion raytrace() in file trace.c
  71.  
  72.  
  73.     Can you please inform me with any bugs that the program might have
  74. or any features that you want the upcoming versions to have.  This software
  75. was written by me, and the subsequent version will probably by produced
  76. by other members of the RPI chapter of the ACM.
  77.                         Good luck!
  78.  
  79.  
  80.     George Kyriazis
  81.     kyriazis@turing.cs.rpi.edu
  82.